//------------------------------------------------------------------------------
#include <QXmlSerializer>
#include <QBuffer>
#include "CConfDefaultReader.h"
//------------------------------------------------------------------------------
CConfDefaultReader *CConfDefaultReader::instance=NULL;
//------------------------------------------------------------------------------
CConfDefaultReader::CConfDefaultReader(void)
{
	query=new QXmlQuery();
}
//------------------------------------------------------------------------------
CConfDefaultReader * CConfDefaultReader::getInstance(void)
{
	if(instance == NULL)
	{
		instance=new CConfDefaultReader();
	}
	
	return instance;
}
//------------------------------------------------------------------------------
QString CConfDefaultReader::getParamValue(QString paramName)
{
	query->setQuery("for $x in doc('confDefault.xml')/conf/property\nwhere $x/@name='"+paramName+"'\nreturn data($x/@value)");
	
	QByteArray byteArray;
	QBuffer buffer(&byteArray);
	buffer.open(QIODevice::WriteOnly);
	QXmlSerializer serializer(*query, &buffer);
	query->evaluateTo(&serializer);
	
	return QString(byteArray);
}
//------------------------------------------------------------------------------